package com.foreknow.demo19;

public class Printer {
    //static Object b = new Object();
    public static void print1(){
        synchronized (Printer.class){
            System.out.print("今");
            System.out.print("晚");
            System.out.print("吃");
            System.out.print("鸡");
            System.out.println();
        }
    }
    public static synchronized void print2() {
            System.out.print("我");
            System.out.print("以");
            System.out.print("为");
            System.out.print("送");
            System.out.print("快");
            System.out.print("递");
            System.out.println();
    }

    public static void main(String[] args) {
//        Printer p = new Printer();
        new Thread(){
            public void run(){
                while (true){
                    print1();
                }
            }
        }.start();

        new Thread(){
            public void run(){
                while (true){
                    print1();
                }
            }
        }.start();
    }
}
